<?php 
	/**
	*企业
	*/
	class InviteControl extends ExtendControl
	{
		public function __init()
		{
			header("Content-type: text/html; charset=utf-8");
		}
		public function index()
		{
			//调用顶级城市
			$cityModel =  K('City');
			$topCity = $cityModel->topCity;
			$this->assign('topCity', $topCity);
			$citynum = $cityModel->get_citynum();
			$this->assign('citynum', $citynum);
			// p($topCity);
			$PosCateModel = K('PosCate');
			//调用顶级职位类别
			$topPos = $PosCateModel->topPos;
			$this->assign('topPos', $topPos);
			$posnum = $PosCateModel->get_posnum();
			$this->assign('posnum', $posnum);
			#调用数据
			$posInfoView = K('PosInfoView');
			// $field = 
			$data = $posInfoView->get_data();
			$this->assign('data',$data);
			$this->display();
		}

		public function search()
		{
			//调用顶级城市
			$cityModel =  K('City');
			$topCity = $cityModel->topCity;
			$sonCity = $cityModel->get_all_son_by_pid(Q('get.city_one',0,'intval'));
			$this->assign('topCity', $topCity);
			$this->assign('sonCity', $sonCity);
			$PosCateModel = K('PosCate');
			//调用顶级职位类别
			$topPos = $PosCateModel->topPos;
			$sonPos = $PosCateModel->get_all_son_by_pid(Q('get.pos_one',0,'intval'));
			$this->assign('topPos', $topPos);
			$this->assign('sonPos', $sonPos);
			// p($sonPos);



			#调用数据
			$posInfoView = K('PosInfoView');
			// $field = 
			$data = $posInfoView->filter_data();
			// p($data);
			$page = $data['page'];
			unset($data['page']);
			$this->assign('data',$data);
			$this->assign('page',$page);
			// p($data);
			//处理弹窗显示的简历
	        //只有是个人用户才分配简历信息
	        if(session('rid') == 1){
	            $model = K('Resume1');
	            //如果检测简历成功以后
	            $status = $model->check_resume();
	            $this->assign('status',$status);

	            if($status){
	                //取得通过的简历
	                $resume = $model->get_pass_resume();
	                // p($resume);
	                $this->assign('resume',$resume);
	            }
	        }
			$this->display();
		}

	    /**
	     * [ajax_check_resume 异步检测用户简历状态]
	     * @return [type] [description]
	     */
	    public function ajax_check_resume(){

	        if(!IS_AJAX) return false;

	        //检测当前用户简历状态
	        $status = K("Resume1")->check_resume();
	        if(!$status) $this->ajax(0);
	        $this->ajax(1);



	    }

	    /**
	     * 0 申请失败
	     * 1 申请成功
	     * 2 申请重复
	     * 3 申请职位一天不能超过10个
	     * [ajax_add_apply 异步申请职位]
	     * @return [type] [description]
	     */
	    public function ajax_add_apply(){
	        if(!IS_AJAX) return false;
	//         Array
	// (
	//     [position_cpid] => 1
	//     [resume1_reid] => 1
	//     [explain] => sdf
	//     [company_uid] => 1
	// )
	        $reid = Q('post.resume1_reid', 0, 'intval');
	        if(!$reid) $this->ajax(0);
	        //检测是否是当前用户的简历
	        K('Resume1')->check_user($reid);

	        $cpid = Q('post.position_cpid', 0, 'intval');
	        if(!$cpid) $this->ajax(0);

	        //职位是否存在
	        $status = K('ComPos')->check_pos_pass($cpid);
	        if(!$status) $this->ajax(0);

	        $model = K('Apply');
	        //是否申请重复
	        if($model->check_apply($cpid,$reid)) $this->ajax(2);

	        //执行模型添加，一天不能超过10个职位
	        if($model->add_data($cpid,$reid,Q('post.company_uid'))) {
	            //添加成功
	            $this->ajax(1);
	        }
	        //申请每天总数不能超过10个
	        $this->ajax(3);

	    }
	}



?>